package com.szeldon.pj.jps.exp;

import com.szeldon.pj.jps.data.store.SBAStore;
import com.szeldon.pj.jps.datastore.SimpleObject;
import com.szeldon.pj.jps.envs.ENVS;
import com.szeldon.pj.jps.qres.AbstractQueryResult;
import com.szeldon.pj.jps.qres.BinderResult;
import com.szeldon.pj.jps.qres.QResStack;
import com.szeldon.pj.jps.visitor.ASTVisitor;

public class GroupasBinaryExpression extends BinaryExpression {

	public GroupasBinaryExpression(Expression leftExpression, Expression rightExpression) {
		super(leftExpression, rightExpression);
		// TODO Auto-generated constructor stub
	}

	@Override
	public int compareTo(SimpleObject object) throws IllegalStateException {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public String getValueAsString() {
		// TODO Auto-generated method stub
		return null;
	}

	public void accept(ASTVisitor astVisitor, ENVS envs, QResStack qResStack, SBAStore store) {

		if (!(rightExpression instanceof NameExpression)) {
			throw new IllegalStateException("Right expression for Groupas must be name expression. "
					+ "Currently it's " + rightExpression.getClass().getName() + ".");
		}

		astVisitor.accept(leftExpression);
		AbstractQueryResult leftResult = qResStack.pop();

		String name = ((NameExpression) rightExpression).getName();
		qResStack.push(new BinderResult(name, leftResult));

	}

}
